Skip to content

Conversation

@pwighton
Copy link
Contributor

@pwighton pwighton commented Nov 20, 2025

Running updatepetjson gives:

Traceback (most recent call last):
  File "/home/paul/miniconda3/envs/pet2bids/bin/updatepetjson", line 3, in <module>
    from pypet2bids.update_json import update_json_cli
ModuleNotFoundError: No module named 'pypet2bids.update_json'

And running ecatheaderupdate gives:

Traceback (most recent call last):
  File "/home/paul/miniconda3/envs/pet2bids/bin/updatepetjson", line 3, in <module>
    from pypet2bids.update_json import update_json_cli
ModuleNotFoundError: No module named 'pypet2bids.update_json'

These errors can be fixed by the changes to pyproject.toml

But then, trying to run updatepetjson gives the following error:

Traceback (most recent call last):
  File "/home/paul/lcn/git/pet2bids/pypet2bids/pypet2bids/update_json_pet_file.py", line 17, in <module>
    import helper_functions
ModuleNotFoundError: No module named 'helper_functions'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/paul/lcn/git/pet2bids/pypet2bids/pypet2bids/is_pet.py", line 15, in <module>
    import helper_functions
ModuleNotFoundError: No module named 'helper_functions'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/paul/lcn/git/pet2bids/pypet2bids/pypet2bids/ecat.py", line 19, in <module>
    import helper_functions
ModuleNotFoundError: No module named 'helper_functions'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/paul/lcn/git/pet2bids/pypet2bids/pypet2bids/dcm2niix4pet.py", line 34, in <module>
    import helper_functions
ModuleNotFoundError: No module named 'helper_functions'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/paul/miniconda3/envs/pet2bids/bin/updatepetjson", line 3, in <module>
    from pypet2bids.update_json_pet_file import update_json_cli
  File "/home/paul/lcn/git/pet2bids/pypet2bids/pypet2bids/update_json_pet_file.py", line 22, in <module>
    import pypet2bids.is_pet as is_pet
  File "/home/paul/lcn/git/pet2bids/pypet2bids/pypet2bids/is_pet.py", line 21, in <module>
    import pypet2bids.ecat as ecat
  File "/home/paul/lcn/git/pet2bids/pypet2bids/pypet2bids/ecat.py", line 34, in <module>
    import pypet2bids.dcm2niix4pet as dcm2niix4pet
  File "/home/paul/lcn/git/pet2bids/pypet2bids/pypet2bids/dcm2niix4pet.py", line 54, in <module>
    from pypet2bids.update_json_pet_file import (
ImportError: cannot import name 'check_json' from partially initialized module 'pypet2bids.update_json_pet_file' (most likely due to a circular import) (/home/paul/lcn/git/pet2bids/pypet2bids/pypet2bids/update_json_pet_file.py)

This is due to a circular dependency:

  • update_json_pet_file.py imports from is_pet.py
  • is_pet.py imports ecat.py
  • ecat.py imports dcm2niix4pet.py
  • dcm2niix4pet.py imports from update_json_pet_file.py

Deferring the import of is_pet to the function where it's used, get_metadata_from_spreadsheet() resolves this.

Running ecatheaderupdate gives:

Traceback (most recent call last):
  File "/home/paul/lcn/git/pet2bids/pypet2bids/pypet2bids/ecat_header_update.py", line 2, in <module>
    import ecat
ModuleNotFoundError: No module named 'ecat'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/paul/miniconda3/envs/pet2bids/bin/ecatheaderupdate", line 3, in <module>
    from pypet2bids.ecat_header_update import cli
  File "/home/paul/lcn/git/pet2bids/pypet2bids/pypet2bids/ecat_header_update.py", line 7, in <module>
    from pypet2bids.ecat import ecat
ImportError: cannot import name 'ecat' from 'pypet2bids.ecat' (/home/paul/lcn/git/pet2bids/pypet2bids/pypet2bids/ecat.py)

Fixing the import statement to import the modules themselves instead of objetcs from modules resolves this.


📚 Documentation preview 📚: https://pet2bids--369.org.readthedocs.build/en/369/

@bendhouseart
Copy link
Contributor

I thought I fixed this, but I must have dreamed that I moved all the import try excepts to pypet2bids/pypet2bids/__init__.py Thanks Paul, will test and merge later today.

Copy link
Contributor

@bendhouseart bendhouseart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@bendhouseart bendhouseart merged commit f7a7ffe into openneuropet:main Nov 21, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants